package com.xframe.xdal.core.param.builder;


import com.xframe.xdal.core.param.*;
import java.util.*;

public class OracleParamFactory implements IBuilderFactory{

    private static Map<Class<?>, IParamSet> map = new HashMap<>();

    static DefParamSet defParamSet = new DefParamSet();
    static {
        map.put(Date.class,new TimestampParamSet());
        map.put(java.sql.Date.class,new SqlDateParamSet());
        map.put(java.sql.Timestamp.class,new TimestampParamSet());
        map.put(java.io.InputStream.class,new BlobParamSet());
        map.put(Enum.class,new EnumParamSet());
    }


    private static OracleParamFactory oracleParamFactory  = new OracleParamFactory();

    public static OracleParamFactory getInstance(){
        return oracleParamFactory;
    }

    public IParamSet getParamSet(Class<?> dataType){
        if(java.io.InputStream.class.isAssignableFrom(dataType)){
            return map.get(java.io.InputStream.class);
        }
        if(dataType.isEnum()){
            return map.get(Enum.class);
        }
        IParamSet paramSet = map.get(dataType);
        return paramSet == null?defParamSet:paramSet;
    }

}
